<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
      list-style: none;
      text-decoration: none;
    }
    .box{
      width: 920px;
      margin:50px auto;
      border: 1px solid red;
    }
    .box .public{
      width: 100%;
    }
    .title{
      width: 100%;
      height: 50px;
      line-height: 50px;
      text-align: center
    }
    .title li{
      float:left;
    }
    .title li a{
      display: block;
      width: 184px;
      height: 50px;
      color:black;
      background-color: #ccc;
    }
    .active{
      background-color: #fff !important;
      color:red !important;
      border-top:2px solid red;
    }
  </style>
</head>
<body>
  <div class="box">
    <div class="title">
      <ul>
        <li><a href="#" class="active">疯狂抢购</a></li>
        <li><a href="#">热卖推荐</a></li>
        <li><a href="#">猜你喜欢</a></li>
        <li><a href="#">新品上架</a></li>
        <li><a href="#">整箱特卖</a></li>
      </ul>
    </div>
    <div class="content">
      <div id="o1" class="public o1"><img src="img/01.bmp" alt=""></div>
      <div id="o2" class="public o2" style="display: none;"><img src="img/02.bmp" alt=""></div>
      <div id="o3" class="public o3" style="display: none;"><img src="img/03.bmp" alt=""></div>
      <div id="o4" class="public o4" style="display: none;"><img src="img/04.bmp" alt=""></div>
      <div id="o5" class="public o5" style="display: none;"><img src="img/05.bmp" alt=""></div>
    </div> 
  </div>
  <script>
    var a_btn = document.querySelectorAll('a');
    var public = document.querySelectorAll('.public')
   for(var i = 0; i <a_btn.length; i++){
     a_btn[i].index = 'o'+(i+1);
    a_btn[i].onmouseenter = function(){
      document.querySelector('.active').classList.remove('active');
      this.classList.add('active');
      for(var j = 0;  j < public.length; j++){
        public[j].style.display = 'none';
      }
      document.getElementById(this.index).style.display = 'block'
    }
  }
  </script>
</body>
</html>